#include "widget.h"

#include <QApplication>
#include <QCoreApplication>
#include <QDesktopWidget>
#include <QDir>
#include <QHttpPart>
#include <QNetworkReply>
#include <QNetworkRequest>

int main(int argc, char *argv[])
{
    QApplication a(argc, argv);


    // 获取可执行文件所在的目录
    QString exeDir = QCoreApplication::applicationDirPath();
    qDebug() << "Executable directory:" << exeDir;

    // 设置当前工作目录为可执行文件所在的目录
    QDir::setCurrent(exeDir);

    QSettings *settings = new QSettings("./config/systemConfig.ini", QSettings::IniFormat);
    qDebug() << "Settings file path (absolute):" << settings->fileName();

    if(settings)
    {
        delete settings;
    }

    Widget w;

    // 获取屏幕中央的坐标
    QDesktopWidget *desktop = QApplication::desktop();
    QRect screenGeometry = desktop->screenGeometry();
    int screenWidth = screenGeometry.width();
    int screenHeight = screenGeometry.height();
    QPoint screenCenter = desktop->availableGeometry().center();

    // 设置窗体的位置在屏幕中央
    w.setGeometry(screenWidth/2 - w.width()/2, screenHeight/2 - w.height()/2, w.width(), w.height());

    w.show();

    return a.exec();
}
